package com.tfswx.jcyw.dmzc.util;

import com.intellij.notification.Notification;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.tfswx.jcyw.dmzc.service.DlxxService;
import com.tfswx.jcyw.dmzc.window.DmzcSettingWindow;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;

public final class NotificationUtil {

    private NotificationUtil() {
    }


    public static Notification create(String message, String title, NotificationType notificationType) {
        NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("dmzc");
        return notificationGroup.createNotification(message, notificationType).setTitle(title);
    }

    public static void showLogin(Project project) {
        Notification notification = NotificationUtil.create("未登录！", "代码走查", NotificationType.WARNING);
        notification.addAction(new AnAction("登录") {
            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                DmzcSettingWindow.openSetting(project);
            }
        });
        notification.notify(project);
    }
}
